<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>行政论坛投稿管理</title>
<%@ include file="/module/js.jsp"%>
	 <script type="text/javascript">		   
		     function formaterSubject(value, row, index) {
		        return "<a href='${basePath}/forumContributions/modiftyForumContributionsForWard?tgid=" + row.tgid +"'>" + value + "</a>";
	         }
		 
			$(document).ready(
							function() {
	                             $('#dg').datagrid({
	                             onClickRow: function (rowIndex, rowData) {
	                    	        $(this).datagrid('unselectRow', rowIndex);
	                    	     },
								 /*onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   window.setTimeout(function(){
									   $.post("${basePath}/forumContributions/jkyContributionList",{orderFlag:_order,orderField:_sort,
										   subject: $('#subject').val(),
										   beginTime :$('#beginTime').val(),
									       endTime :$('#endTime').val()
									     
									    },function(data){
										 $('#dg').datagrid("loadData",data); 
										});
								       },100);  
								   },*/onLoadSuccess: function(data){//加载完毕后获取所有的checkbox遍历
						                 if (data.rows.length > 0) {
							                    //循环判断操作为新增的不能选择
							                    var checkbox = $("input[type='checkbox']");
							                    for (var i = 0; i < data.rows.length; i++) {
							                        //根据operate让某些行不可选
							                        if (data.rows[i].isValid==0) {
								                       $(checkbox.get(i+1)).remove();
							                        }
							                    }
							                }
									   },
								   rowStyler: function(index,row){
								   },
								
	                          });
								
								$('#btnAdd').click(function() {
								  document.Form.action = "${basePath}/forumContributions/addForumContributionsForward";
								  document.Form.submit();
								});
								
								//查询
								$('#btnQuery')
										.click(
												function() {
													$('#dg').datagrid('load',{
														 subject: $('#subject').val(),
														 beginTime :$('#beginTime').val(),
													     endTime :$('#endTime').val()
													});
												});
								
								$('#btnDelete').click(function() {
						               $("#idList").val("");
										var count = 0;
										var idList = new Array();
									    var sels = $("#dg").datagrid("getSelections");
								    	for(var i in sels){
								    	   if (sels[i].isValid!=0) {
								    		idList.push(sels[i].tgid);
								    		count++;
								    		}
								    	}
										
										if (count == 0) {
											layer.alert("您至少选择一条删除记录信息", {icon: 3});
											return false;
										}else{
											  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
												    $("#idList").val(idList);
												    document.Form.action = "${basePath}/forumContributions/deleteForumContributions";
													document.Form.submit();
											  },function(index){
													layer.close(index);
											  });
										}
									});
								 $('#easyui-ck').click(function() {
									    var data = $("#dg").datagrid("getSelections");
					                 for (var i = 0; i < data.length; i++) {
					                     if (data[i].isValid== 0) {
						                     $('#dg').datagrid('unselectRow',i);
						                     $("#easyui-ck").attr('checked','checked'); 
					                     }
					                 }
									}); 
			
		         });
			
			
		 if("${msg}"!=""){
		       layer.alert("${msg}", {icon: 6});
		 } 
				
		</script>

</head>
<body>
	<form action="#" name="Form" id="Form" method="post">
		<input type="hidden" name="idList" id="idList"/>
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" value="查询"
					class="inputButton" /></td>
				   <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_WDXJLTTG\")%>" key="add">	
				<td><input type="button" id="btnAdd"  value="添 加 "
					class="inputButton" /></td>
				 </kl:permission>
			  <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"JKY_JKS_WDXJLTTG\")%>" key="delete">	 
				<td><input type="button" id="btnDelete" value="删除"
					 class="inputButton"/></td>
				 </kl:permission> 
			</tr>
		</table>
	   <table cellpadding="1" cellspacing="1">
			<tr>
				<td>主题：</td>
				<td><input type="text" name="subject" id="subject"  autocomplete="off" class="inputText2" /></td>
				<td>投稿日期：</td>
				<td>从<input type="text" name="beginTime" id="beginTime"  autocomplete="off" class="Wdate inputText2" readonly  onClick="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endTime\',{});}'})" />到&nbsp;&nbsp;<input type="text" name="endTime" id="endTime"  autocomplete="off" class="Wdate inputText2" readonly  onClick="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'beginTime\',{d:1});}'})" /></td>
			</tr>
		</table>
		<br/>
        <table id="dg"  style="width:60%;"
		data-options="pagination:true,collapsible:true,url:'${basePath}/forumContributions/jkyContributionList',method:'post',remoteSort:true,striped:true"> 
		<thead>
			<tr>
				<th data-options="field:'tgid',checkbox:true,width:60,align:'left'"></th>
				<th data-options="field:'createtime',sortable:true,nowrap:true,width:300,align:'left',formatter:formatDate">投稿时间</th>
				<th data-options="field:'docnum',sortable:true,nowrap:true,width:100,align:'left'">投稿数量</th>
				<th data-options="field:'subject',sortable:true,nowrap:true,width:300,align:'left',formatter:formaterSubject">主题</th>
			    <th data-options="field:'remark',sortable:true,nowrap:true,width:200,align:'left'">备注</th>
			</tr>
		</thead>
	</table>
	</form>
</body>
</html>
